import type { IAggregate, Dictionary, AsyncDataResult, AggregateParams } from '../../types'
import { HttpClient } from '../../HttpClient'

export class AggregateAPI implements IAggregate {
  private httpClient: HttpClient

  constructor(httpClient: HttpClient) {
    this.httpClient = httpClient
  }

  public async count(params: AggregateParams): AsyncDataResult<number> {
    return await this.httpClient.request<AggregateParams, number>('aggregate_count', params)
  }
  public async sum(params: AggregateParams): AsyncDataResult<number> {
    return await this.httpClient.request<AggregateParams, number>('aggregate_sum', params)
  }
  public async avg(params: AggregateParams): AsyncDataResult<number> {
    return await this.httpClient.request<AggregateParams, number>('aggregate_avg', params)
  }
  public async max(params: AggregateParams): AsyncDataResult<number> {
    return await this.httpClient.request<AggregateParams, number>('aggregate_max', params)
  }
  public async min(params: AggregateParams): AsyncDataResult<number> {
    return await this.httpClient.request<AggregateParams, number>('aggregate_min', params)
  }

}
